package com.gorillalogic.scrummonkey.events {
	import flash.events.EventDispatcher;

	public class ScrumEventBus extends EventDispatcher {
		private static const _instance:ScrumEventBus = new ScrumEventBus(SingletonLock);

		public function ScrumEventBus(lock:Class) {
			if (lock != SingletonLock) {
				throw new Error("Bad access. Use ScrumEventBus.instance");
			}
		}

		public static function get instance():ScrumEventBus {
			return _instance;
		}

		public function addListener(type:String, handler:Function):void {
			_instance.addEventListener(type, handler);
		}

		public function removeListener(type:String, handler:Function):void {
			_instance.removeEventListener(type, handler);
		}

		public function dispatchScrumEvent(type:String, data:Object = null):void {
			_instance.dispatchEvent(new ScrumEvent(type, data));
		}
		public function dispatchColorEvent(type:String, releaseId:int=-1, iterationId:int=-1):void {
			_instance.dispatchEvent(new ColorEvent(type, releaseId, iterationId));
		}
	}
}

class SingletonLock { };